home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / bitmap.c < prev    next >
C/C++ Source or Header  |  1993-09-15  |  52KB  |  1,075 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: bitmap.c%v 3.50 1993/07/09 05:35:24 woo Exp $";
  3. #endif
  4.  
  5.  
  6. /* GNUPLOT - bitmap.c */
  7. /*
  8.  * Copyright (C) 1986 - 1993   Thomas Williams, Colin Kelley
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software is provided "as is" without express or implied warranty.
  21.  * 
  22.  *
  23.  * AUTHORS
  24.  * 
  25.  *   Original Software:
  26.  *     Jyrki Yli-Nokari <jty@intrin.UUCP>
  27.  *     Ronald J. Hartranft <rjh2@ns.cc.lehigh.edu>
  28.  *     Russell Lang <rjl@monu1.cc.monash.edu.au>
  29.  * 
  30.  * There is a mailing list for gnuplot users. Note, however, that the
  31.  * newsgroup 
  32.  *    comp.graphics.gnuplot 
  33.  * is identical to the mailing list (they
  34.  * both carry the same set of messages). We prefer that you read the
  35.  * messages through that newsgroup, to subscribing to the mailing list.
  36.  * (If you can read that newsgroup, and are already on the mailing list,
  37.  * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  38.  * removed from the mailing list.)
  39.  *
  40.  * The address for mailing to list members is
  41.  *       info-gnuplot@dartmouth.edu
  42.  * and for mailing administrative requests is 
  43.  *       info-gnuplot-request@dartmouth.edu
  44.  * The mailing list for bug reports is 
  45.  *       bug-gnuplot@dartmouth.edu
  46.  * The list of those interested in beta-test versions is
  47.  *       info-gnuplot-beta@dartmouth.edu
  48.  */
  49.  
  50. /*
  51. ** General raster plotting routines.
  52. ** Raster routines written and copyrighted 1987 by
  53. ** Jyrki Yli-Nokari (jty@intrin.UUCP)
  54. ** Intrinsic, Ltd.
  55. **
  56. ** You may use this code for anything you like as long as
  57. ** you are not selling it and the credit is given and
  58. ** this message retained.
  59. **
  60. */
  61.  
  62. /* Bitmap plotting routines derived from above raster plotting routines
  63.  * Russell Lang, 1990
  64.  */
  65.  
  66. #include <stdio.h>
  67. #include "plot.h"
  68. #include "bitmap.h"
  69.  
  70. bitmap *b_p = (bitmap *)NULL;    /* global pointer to bitmap */
  71. unsigned int b_currx, b_curry;    /* the current coordinates */
  72. unsigned int b_xsize, b_ysize;    /* the size of the bitmap */
  73. unsigned int b_planes;            /* number of color planes */
  74. unsigned int b_psize;            /* size of each plane */
  75. unsigned int b_rastermode;        /* raster mode rotates -90deg */
  76. unsigned int b_linemask = 0xffff;    /* 16 bit mask for dotted lines */
  77. unsigned int b_value = 1;        /* colour of lines */
  78. unsigned int b_hchar;            /* width of characters */
  79. unsigned int b_hbits;            /* actual bits in char horizontally */
  80. unsigned int b_vchar;            /* height of characters */
  81. unsigned int b_vbits;            /* actual bits in char vertically */
  82. unsigned int b_angle;            /* rotation of text */
  83. char_box b_font[FNT_CHARS];    /* the current font */
  84. unsigned int b_pattern[] = {0xffff, 0x1111,
  85.     0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
  86. int b_maskcount = 0;
  87. unsigned int b_lastx, b_lasty;    /* last pixel set - used by b_line */
  88.  
  89. #define IN(i,size)  ((unsigned)i < (unsigned)size)
  90.  
  91. /* 5x9 font, bottom row first, left pixel in lsb */
  92. char_row GPFAR fnt5x9[FNT_CHARS][FNT5X9_VBITS] = {
  93.   /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000},
  94.   /*!*/  {000000,000000,0x0004,000000,0x0004,0x0004,0x0004,0x0004,0x0004},
  95.   /*"*/  {000000,000000,000000,000000,000000,000000,0x000a,0x000a,0x000a},
  96.   /*#*/  {000000,000000,0x000a,0x000a,0x001f,0x000a,0x001f,0x000a,0x000a},
  97.   /*$*/  {000000,000000,0x0004,0x000f,0x0014,0x000e,0x0005,0x001e,0x0004},
  98.   /*%*/  {000000,000000,0x0018,0x0019,0x0002,0x0004,0x0008,0x0013,0x0003},
  99.   /*&*/  {000000,000000,0x0016,0x0009,0x0015,0x0002,0x0005,0x0005,0x0002},
  100.   /*'*/  {000000,000000,000000,000000,000000,0x0002,0x0004,0x0006,0x0006},
  101.   /*(*/  {000000,000000,0x0008,0x0004,0x0002,0x0002,0x0002,0x0004,0x0008},
  102.   /*)*/  {000000,000000,0x0002,0x0004,0x0008,0x0008,0x0008,0x0004,0x0002},
  103.   /***/  {000000,000000,0x0004,0x0015,0x000e,0x001f,0x000e,0x0015,0x0004},
  104.   /*+*/  {000000,000000,000000,0x0004,0x0004,0x001f,0x0004,0x0004,000000},
  105.   /*,*/  {000000,0x0002,0x0004,0x0006,0x0006,000000,000000,000000,000000},
  106.   /*-*/  {000000,000000,000000,000000,000000,0x001f,000000,000000,000000},
  107.   /*.*/  {000000,000000,0x0006,0x0006,000000,000000,000000,000000,000000},
  108.   /*-/-*/{000000,000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,000000},
  109.   /*0*/  {000000,000000,0x000e,0x0011,0x0013,0x0015,0x0019,0x0011,0x000e},
  110.   /*1*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0006,0x0004},
  111.   /*2*/  {000000,000000,0x001f,0x0001,0x0001,0x000e,0x0010,0x0011,0x000e},
  112.   /*3*/  {000000,000000,0x000e,0x0011,0x0010,0x000c,0x0010,0x0011,0x000e},
  113.   /*4*/  {000000,000000,0x0008,0x0008,0x001f,0x0009,0x000a,0x000c,0x0008},
  114.   /*5*/  {000000,000000,0x000e,0x0011,0x0010,0x0010,0x000f,0x0001,0x001f},
  115.   /*6*/  {000000,000000,0x000e,0x0011,0x0011,0x000f,0x0001,0x0002,0x000c},
  116.   /*7*/  {000000,000000,0x0001,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
  117.   /*8*/  {000000,000000,0x000e,0x0011,0x0011,0x000e,0x0011,0x0011,0x000e},
  118.   /*9*/  {000000,000000,0x0006,0x0008,0x0010,0x001e,0x0011,0x0011,0x000e},
  119.   /*:*/  {000000,000000,000000,0x0006,0x0006,000000,0x0006,0x0006,000000},
  120.   /*;*/  {000000,0x0001,0x0002,0x0006,0x0006,000000,0x0006,0x0006,000000},
  121.   /*<*/  {000000,000000,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,0x0008},
  122.   /*=*/  {000000,000000,000000,000000,0x001f,000000,0x001f,000000,000000},
  123.   /*>*/  {000000,000000,0x0002,0x0004,0x0008,0x0010,0x0008,0x0004,0x0002},
  124.   /*?*/  {000000,000000,0x0004,000000,0x0004,0x0008,0x0010,0x0011,0x000e},
  125.   /*@*/  {000000,000000,0x000e,0x0015,0x0015,0x0016,0x0010,0x0011,0x000e},
  126.   /*A*/  {000000,000000,0x0011,0x0011,0x001f,0x0011,0x0011,0x000a,0x0004},
  127.   /*B*/  {000000,000000,0x000f,0x0012,0x0012,0x000e,0x0012,0x0012,0x000f},
  128.   /*C*/  {000000,000000,0x000e,0x0011,0x0001,0x0001,0x0001,0x0011,0x000e},
  129.   /*D*/  {000000,000000,0x000f,0x0012,0x0012,0x0012,0x0012,0x0012,0x000f},
  130.   /*E*/  {000000,000000,0x001f,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
  131.   /*F*/  {000000,000000,0x0001,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
  132.   /*G*/  {000000,000000,0x001e,0x0011,0x0011,0x0019,0x0001,0x0001,0x001e},
  133.   /*H*/  {000000,000000,0x0011,0x0011,0x0011,0x001f,0x0011,0x0011,0x0011},
  134.   /*I*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x000e},
  135.   /*J*/  {000000,000000,0x000e,0x0011,0x0010,0x0010,0x0010,0x0010,0x0010},
  136.   /*K*/  {000000,000000,0x0011,0x0009,0x0005,0x0003,0x0005,0x0009,0x0011},
  137.   /*L*/  {000000,000000,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  138.   /*M*/  {000000,000000,0x0011,0x0011,0x0011,0x0015,0x0015,0x001b,0x0011},
  139.   /*N*/  {000000,000000,0x0011,0x0011,0x0011,0x0019,0x0015,0x0013,0x0011},
  140.   /*O*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x000e},
  141.   /*P*/  {000000,000000,0x0001,0x0001,0x0001,0x000f,0x0011,0x0011,0x000f},
  142.   /*Q*/  {000000,0x0018,0x000e,0x0015,0x0011,0x0011,0x0011,0x0011,0x000e},
  143.   /*R*/  {000000,000000,0x0011,0x0009,0x0005,0x000f,0x0011,0x0011,0x000f},
  144.   /*S*/  {000000,000000,0x000e,0x0011,0x0010,0x000e,0x0001,0x0011,0x000e},
  145.   /*T*/  {000000,000000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x001f},
  146.   /*U*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x0011},
  147.   /*V*/  {000000,000000,0x0004,0x0004,0x000a,0x000a,0x0011,0x0011,0x0011},
  148.   /*W*/  {000000,000000,0x0011,0x001b,0x0015,0x0011,0x0011,0x0011,0x0011},
  149.   /*X*/  {000000,000000,0x0011,0x0011,0x000a,0x0004,0x000a,0x0011,0x0011},
  150.   /*Y*/  {000000,000000,0x0004,0x0004,0x0004,0x0004,0x000a,0x0011,0x0011},
  151.   /*Z*/  {000000,000000,0x001f,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
  152.   /*[*/  {000000,000000,0x000e,0x0002,0x0002,0x0002,0x0002,0x0002,0x000e},
  153.   /*\*/  {000000,000000,000000,0x0010,0x0008,0x0004,0x0002,0x0001,000000},
  154.   /*]*/  {000000,000000,0x000e,0x0008,0x0008,0x0008,0x0008,0x0008,0x000e},
  155.   /*^*/  {000000,000000,000000,000000,000000,000000,0x0011,0x000a,0x0004},
  156.   /*_*/  {000000,000000,0x001f,000000,000000,000000,000000,000000,000000},
  157.   /*`*/  {000000,000000,000000,000000,000000,0x0008,0x0004,0x000c,0x000c},
  158.   /*a*/  {000000,000000,0x001e,0x0011,0x001e,0x0010,0x000e,000000,000000},
  159.   /*b*/  {000000,000000,0x000d,0x0013,0x0011,0x0013,0x000d,0x0001,0x0001},
  160.   /*c*/  {000000,000000,0x000e,0x0011,0x0001,0x0011,0x000e,000000,000000},
  161.   /*d*/  {000000,000000,0x0016,0x0019,0x0011,0x0019,0x0016,0x0010,0x0010},
  162.   /*e*/  {000000,000000,0x000e,0x0001,0x001f,0x0011,0x000e,000000,000000},
  163.   /*f*/  {000000,000000,0x0004,0x0004,0x0004,0x000e,0x0004,0x0014,0x0008},
  164.   /*g*/  {0x000e,0x0011,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
  165.   /*h*/  {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,0x0001,0x0001},
  166.   /*i*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0006,000000,0x0004},
  167.   /*j*/  {0x0006,0x0009,0x0008,0x0008,0x0008,0x0008,0x000c,000000,0x0008},
  168.   /*k*/  {000000,000000,0x0009,0x0005,0x0003,0x0005,0x0009,0x0001,0x0001},
  169.   /*l*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x0006},
  170.   /*m*/  {000000,000000,0x0015,0x0015,0x0015,0x0015,0x000b,000000,000000},
  171.   /*n*/  {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,000000,000000},
  172.   /*o*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x000e,000000,000000},
  173.   /*p*/  {0x0001,0x0001,0x000d,0x0013,0x0011,0x0013,0x000d,000000,000000},
  174.   /*q*/  {0x0010,0x0010,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
  175.   /*r*/  {000000,000000,0x0001,0x0001,0x0001,0x0013,0x000d,000000,000000},
  176.   /*s*/  {000000,000000,0x000f,0x0010,0x000e,0x0001,0x001e,000000,000000},
  177.   /*t*/  {000000,000000,0x0008,0x0014,0x0004,0x0004,0x001f,0x0004,0x0004},
  178.   /*u*/  {000000,000000,0x0016,0x0019,0x0011,0x0011,0x0011,000000,000000},
  179.   /*v*/  {000000,000000,0x0004,0x000a,0x0011,0x0011,0x0011,000000,000000},
  180.   /*w*/  {000000,000000,0x000a,0x0015,0x0015,0x0011,0x0011,000000,000000},
  181.   /*x*/  {000000,000000,0x0011,0x000a,0x0004,0x000a,0x0011,000000,000000},
  182.   /*y*/  {0x000e,0x0010,0x001e,0x0011,0x0011,0x0011,0x0011,000000,000000},
  183.   /*z*/  {000000,000000,0x001f,0x0002,0x0004,0x0008,0x001f,000000,000000},
  184.   /*{*/  {000000,000000,0x0008,0x0004,0x0004,0x0002,0x0004,0x0004,0x0008},
  185.   /*|*/  {000000,000000,0x0004,0x0004,0x0004,000000,0x0004,0x0004,0x0004},
  186.   /*}*/  {000000,000000,0x0002,0x0004,0x0004,0x0008,0x0004,0x0004,0x0002},
  187.   /*~*/  {000000,000000,000000,000000,000000,000000,0x0008,0x0015,0x0002},
  188.   /*DEL*/{000000,000000,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f},
  189. };
  190.  
  191. /* 9x17 font, bottom row first, left pixel in lsb */
  192. char_row GPFAR fnt9x17[FNT_CHARS][FNT9X17_VBITS] = {
  193.   /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  194.           000000,000000,000000,000000,000000,000000,000000,000000},
  195.   /*!*/  {000000,000000,000000,000000,0x0010,000000,000000,000000,0x0010,
  196.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010},
  197.   /*"*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  198.           000000,000000,000000,0x0044,0x0044,0x0044,0x0044,0x0044},
  199.   /*#*/  {000000,000000,000000,000000,0x0044,0x0044,0x0044,0x0044,0x01ff,
  200.           0x0044,0x0044,0x0044,0x01ff,0x0044,0x0044,0x0044,0x0044},
  201.   /*$*/  {000000,000000,000000,000000,0x0010,0x0010,0x007e,0x0091,0x0110,
  202.           0x0090,0x007c,0x0012,0x0011,0x0112,0x00fc,0x0010,0x0010},
  203.   /*%*/  {000000,000000,000000,000000,0x0080,0x0141,0x0081,0x0002,0x0004,
  204.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0102,0x0105,0x0002},
  205.   /*&*/  {000000,000000,000000,000000,0x011c,0x00a2,0x0041,0x00c1,0x0141,
  206.           0x0022,0x001c,0x0014,0x0022,0x0022,0x001c,000000,000000},
  207.   /*'*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  208.           000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010},
  209.   /*(*/  {000000,000000,000000,000000,0x0040,0x0020,0x0010,0x0008,0x0008,
  210.           0x0004,0x0004,0x0004,0x0008,0x0008,0x0010,0x0020,0x0040},
  211.   /*)*/  {000000,000000,000000,000000,0x0004,0x0008,0x0010,0x0020,0x0020,
  212.           0x0040,0x0040,0x0040,0x0020,0x0020,0x0010,0x0008,0x0004},
  213.   /***/  {000000,000000,000000,000000,0x0010,0x0010,0x0111,0x0092,0x0054,
  214.           0x0038,0x01ff,0x0038,0x0054,0x0092,0x0111,0x0010,0x0010},
  215.   /*+*/  {000000,000000,000000,000000,000000,000000,0x0010,0x0010,0x0010,
  216.           0x0010,0x01ff,0x0010,0x0010,0x0010,0x0010,000000,000000},
  217.   /*,*/  {000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010,000000,
  218.           000000,000000,000000,000000,000000,000000,000000,000000},
  219.   /*-*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  220.           000000,0x01ff,000000,000000,000000,000000,000000,000000},
  221.   /*.*/  {000000,000000,000000,000000,0x0010,0x0038,0x0010,000000,000000,
  222.           000000,000000,000000,000000,000000,000000,000000,000000},
  223.   /*-/-*/{000000,000000,000000,000000,000000,000000,0x0001,0x0002,0x0004,
  224.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,000000,000000},
  225.   /*0*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0103,0x0105,
  226.           0x0109,0x0111,0x0121,0x0141,0x0181,0x0101,0x0082,0x007c},
  227.   /*1*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  228.           0x0010,0x0010,0x0010,0x0010,0x0010,0x001c,0x0018,0x0010},
  229.   /*2*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0001,0x0001,0x0001,
  230.           0x0002,0x007c,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  231.   /*3*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  232.           0x0080,0x0078,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  233.   /*4*/  {000000,000000,000000,000000,0x0040,0x0040,0x0040,0x0040,0x0040,
  234.           0x01ff,0x0041,0x0042,0x0044,0x0048,0x0050,0x0060,0x0040},
  235.   /*5*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  236.           0x0100,0x0080,0x007f,0x0001,0x0001,0x0001,0x0001,0x01ff},
  237.   /*6*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  238.           0x0081,0x007f,0x0001,0x0001,0x0001,0x0002,0x0084,0x0078},
  239.   /*7*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0002,0x0004,
  240.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0100,0x01ff},
  241.   /*8*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  242.           0x0082,0x007c,0x0082,0x0101,0x0101,0x0101,0x0082,0x007c},
  243.   /*9*/  {000000,000000,000000,000000,0x001c,0x0022,0x0040,0x0080,0x0100,
  244.           0x0100,0x01fc,0x0102,0x0101,0x0101,0x0101,0x0082,0x007c},
  245.   /*:*/  {000000,000000,000000,000000,000000,000000,0x0010,0x0038,0x0010,
  246.           000000,000000,000000,0x0010,0x0038,0x0010,000000,000000},
  247.   /*;*/  {000000,000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010,
  248.           000000,000000,000000,0x0010,0x0038,0x0010,000000,000000},
  249.   /*<*/  {000000,000000,000000,000000,0x0040,0x0020,0x0010,0x0008,0x0004,
  250.           0x0002,0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040},
  251.   /*=*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x01ff,
  252.           000000,000000,000000,0x01ff,000000,000000,000000,000000},
  253.   /*>*/  {000000,000000,000000,000000,0x0004,0x0008,0x0010,0x0020,0x0040,
  254.           0x0080,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004},
  255.   /*?*/  {000000,000000,000000,0x0010,0x0038,0x0010,000000,0x0010,0x0010,
  256.           0x0020,0x0040,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  257.   /*@*/  {000000,000000,000000,000000,0x007c,0x0002,0x0001,0x01f9,0x0145,
  258.           0x0145,0x0145,0x0179,0x0101,0x0101,0x0101,0x0082,0x007c},
  259.   /*A*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x01ff,
  260.           0x0101,0x0082,0x0082,0x0044,0x0044,0x0028,0x0028,0x0010},
  261.   /*B*/  {000000,000000,000000,000000,0x007f,0x0084,0x0104,0x0104,0x0104,
  262.           0x0084,0x007c,0x0084,0x0104,0x0104,0x0104,0x0084,0x007f},
  263.   /*C*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0001,0x0001,
  264.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0101,0x0082,0x007c},
  265.   /*D*/  {000000,000000,000000,000000,0x007f,0x0084,0x0104,0x0104,0x0104,
  266.           0x0104,0x0104,0x0104,0x0104,0x0104,0x0104,0x0084,0x007f},
  267.   /*E*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0001,0x0001,0x0001,
  268.           0x0001,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x01ff},
  269.   /*F*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
  270.           0x0001,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x01ff},
  271.   /*G*/  {000000,000000,000000,000000,0x00fc,0x0102,0x0101,0x0101,0x0101,
  272.           0x0101,0x01c1,0x0001,0x0001,0x0001,0x0001,0x0102,0x00fc},
  273.   /*H*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  274.           0x0101,0x01ff,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  275.   /*I*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  276.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x007c},
  277.   /*J*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  278.           0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x0180},
  279.   /*K*/  {000000,000000,000000,000000,0x0101,0x0081,0x0041,0x0021,0x0011,
  280.           0x0009,0x0005,0x000b,0x0011,0x0021,0x0041,0x0081,0x0101},
  281.   /*L*/  {000000,000000,000000,000000,0x01ff,0x0101,0x0001,0x0001,0x0001,
  282.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  283.   /*M*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  284.           0x0101,0x0111,0x0111,0x0129,0x0145,0x0145,0x0183,0x0101},
  285.   /*N*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0181,0x0141,
  286.           0x0141,0x0121,0x0111,0x0109,0x0105,0x0105,0x0103,0x0101},
  287.   /*O*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  288.           0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0082,0x007c},
  289.   /*P*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
  290.           0x0001,0x007f,0x0081,0x0101,0x0101,0x0101,0x0081,0x007f},
  291.   /*Q*/  {000000,000000,0x0180,0x0040,0x007c,0x0092,0x0101,0x0101,0x0101,
  292.           0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0082,0x007c},
  293.   /*R*/  {000000,000000,000000,000000,0x0101,0x0081,0x0041,0x0021,0x0011,
  294.           0x0009,0x007f,0x0081,0x0101,0x0101,0x0101,0x0081,0x007f},
  295.   /*S*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  296.           0x0080,0x007c,0x0002,0x0001,0x0001,0x0101,0x0082,0x007c},
  297.   /*T*/  {000000,000000,000000,000000,0x0038,0x0010,0x0010,0x0010,0x0010,
  298.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0111,0x01ff},
  299.   /*U*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  300.           0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  301.   /*V*/  {000000,000000,000000,000000,0x0010,0x0010,0x0028,0x0028,0x0044,
  302.           0x0044,0x0082,0x0082,0x0101,0x0101,0x0101,0x0101,0x0101},
  303.   /*W*/  {000000,000000,000000,000000,0x0101,0x0183,0x0145,0x0145,0x0129,
  304.           0x0111,0x0111,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  305.   /*X*/  {000000,000000,000000,000000,0x0101,0x0101,0x0082,0x0082,0x0044,
  306.           0x0028,0x0010,0x0028,0x0044,0x0082,0x0082,0x0101,0x0101},
  307.   /*Y*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
  308.           0x0010,0x0010,0x0028,0x0044,0x0082,0x0082,0x0101,0x0101},
  309.   /*Z*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0002,0x0002,0x0004,
  310.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0080,0x0100,0x01ff},
  311.   /*[*/  {000000,000000,000000,000000,0x007c,0x0004,0x0004,0x0004,0x0004,
  312.           0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x007c},
  313.   /*\*/  {000000,000000,000000,000000,000000,000000,0x0100,0x0080,0x0040,
  314.           0x0020,0x0010,0x0008,0x0004,0x0002,0x0001,000000,000000},
  315.   /*]*/  {000000,000000,000000,000000,0x007c,0x0040,0x0040,0x0040,0x0040,
  316.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x007c},
  317.   /*^*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  318.           000000,000000,000000,0x0101,0x0082,0x0044,0x0028,0x0010},
  319.   /*_*/  {000000,000000,000000,000000,0x01ff,000000,000000,000000,000000,
  320.           000000,000000,000000,000000,000000,000000,000000,000000},
  321.   /*`*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  322.           000000,000000,0x0020,0x0010,0x0008,0x000c,0x001c,0x0008},
  323.   /*a*/  {000000,000000,000000,000000,0x03fc,0x0102,0x0101,0x0102,0x01fc,
  324.           0x0100,0x0100,0x0080,0x007c,000000,000000,000000,000000},
  325.   /*b*/  {000000,000000,000000,000000,0x007d,0x0083,0x0101,0x0101,0x0101,
  326.           0x0101,0x0101,0x0083,0x007d,0x0001,0x0001,0x0001,0x0001},
  327.   /*c*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0001,0x0001,
  328.           0x0001,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  329.   /*d*/  {000000,000000,000000,000000,0x017c,0x0182,0x0101,0x0101,0x0101,
  330.           0x0101,0x0101,0x0182,0x017c,0x0100,0x0100,0x0100,0x0100},
  331.   /*e*/  {000000,000000,000000,000000,0x007c,0x0002,0x0001,0x0001,0x01ff,
  332.           0x0101,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  333.   /*f*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
  334.           0x0010,0x007c,0x0010,0x0010,0x0010,0x0110,0x00a0,0x0040},
  335.   /*g*/  {0x007c,0x0082,0x0101,0x0100,0x017c,0x0182,0x0101,0x0101,0x0101,
  336.           0x0101,0x0101,0x0182,0x017c,000000,000000,000000,000000},
  337.   /*h*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  338.           0x0103,0x0103,0x0085,0x0079,0x0001,0x0001,0x0001,0x0001},
  339.   /*i*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  340.           0x0010,0x0010,0x0018,000000,000000,0x0018,0x0018,000000},
  341.   /*j*/  {0x003c,0x0042,0x0081,0x0080,0x0080,0x0080,0x0080,0x0080,0x0080,
  342.           0x0080,0x0080,0x00c0,000000,000000,0x00c0,0x00c0,000000},
  343.   /*k*/  {000000,000000,000000,000000,0x0082,0x0042,0x0022,0x0012,0x000a,
  344.           0x0016,0x0022,0x0042,0x0002,0x0002,0x0002,0x0002,0x0002},
  345.   /*l*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  346.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x001c},
  347.   /*m*/  {000000,000000,000000,000000,0x0111,0x0111,0x0111,0x0111,0x0111,
  348.           0x0111,0x0111,0x00ab,0x0045,000000,000000,000000,000000},
  349.   /*n*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  350.           0x0101,0x0101,0x0083,0x007d,000000,000000,000000,000000},
  351.   /*o*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  352.           0x0101,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  353.   /*p*/  {0x0001,0x0001,0x0001,0x0001,0x007d,0x0003,0x0081,0x0101,0x0101,
  354.           0x0101,0x0101,0x0083,0x007d,000000,000000,000000,000000},
  355.   /*q*/  {0x0100,0x0100,0x0100,0x0100,0x017c,0x0182,0x0101,0x0101,0x0101,
  356.           0x0101,0x0101,0x0182,0x017c,000000,000000,000000,000000},
  357.   /*r*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
  358.           0x0001,0x0103,0x0085,0x0079,000000,000000,000000,000000},
  359.   /*s*/  {000000,000000,000000,000000,0x007e,0x0081,0x0100,0x0080,0x007c,
  360.           0x0002,0x0001,0x0102,0x00fc,000000,000000,000000,000000},
  361.   /*t*/  {000000,000000,000000,000000,0x0040,0x00a0,0x0110,0x0010,0x0010,
  362.           0x0010,0x0010,0x0010,0x00fe,0x0010,0x0010,0x0010,0x0010},
  363.   /*u*/  {000000,000000,000000,000000,0x013c,0x0142,0x0181,0x0101,0x0101,
  364.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  365.   /*v*/  {000000,000000,000000,000000,0x0010,0x0028,0x0044,0x0082,0x0101,
  366.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  367.   /*w*/  {000000,000000,000000,000000,0x0044,0x00aa,0x0111,0x0111,0x0101,
  368.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  369.   /*x*/  {000000,000000,000000,000000,0x0101,0x0082,0x0044,0x0028,0x0010,
  370.           0x0028,0x0044,0x0082,0x0101,000000,000000,000000,000000},
  371.   /*y*/  {0x007c,0x0082,0x0101,0x0100,0x0100,0x01fc,0x0102,0x0101,0x0101,
  372.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  373.   /*z*/  {000000,000000,000000,000000,0x01ff,0x0002,0x0004,0x0008,0x0010,
  374.           0x0020,0x0040,0x0080,0x01ff,000000,000000,000000,000000},
  375.   /*{*/  {000000,000000,000000,000000,0x00c0,0x0020,0x0010,0x0010,0x0010,
  376.           0x0008,0x0004,0x0008,0x0010,0x0010,0x0010,0x0020,0x00c0},
  377.   /*|*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
  378.           000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010},
  379.   /*}*/  {000000,000000,000000,000000,0x0006,0x0008,0x0010,0x0010,0x0010,
  380.           0x0020,0x0040,0x0020,0x0010,0x0010,0x0010,0x0008,0x0006},
  381.   /*~*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  382.           000000,000000,000000,0x0040,0x00a0,0x0111,0x000a,0x0004},
  383.   /*DEL*/{000000,000000,000000,000000,0x0155,000000,0x0155,000000,0x0155,
  384.           000000,0x0155,000000,0x0155,000000,0x0155,000000,0x0155},
  385. };
  386.  
  387. /* 13x25 font, bottom row first, left pixel in lsb */
  388. char_row GPFAR fnt13x25[FNT_CHARS][FNT13X25_VBITS] = {
  389.   /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  390.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  391.           000000,000000,000000,000000,000000,000000,000000},
  392.   /*!*/  {000000,000000,000000,000000,000000,0x00e0,0x00e0,0x00e0,000000,
  393.           000000,000000,0x0040,0x0040,0x0040,0x0040,0x0040,0x00e0,0x00e0,
  394.           0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x0040},
  395.   /*"*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  396.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  397.           0x0208,0x0208,0x0208,0x0208,0x0208,0x0208,0x0208},
  398.   /*#*/  {000000,000000,000000,000000,000000,000000,0x0208,0x0208,0x0208,
  399.           0x0208,0x0208,0x0208,0x1fff,0x0208,0x0208,0x0208,0x0208,0x0208,
  400.           0x1fff,0x0208,0x0208,0x0208,0x0208,0x0208,0x0208},
  401.   /*$*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  402.           0x03f8,0x0444,0x0842,0x0840,0x0840,0x0440,0x03f8,0x0044,0x0042,
  403.           0x0042,0x0842,0x0444,0x03f8,0x0040,0x0040,0x0040},
  404.   /*%*/  {000000,000000,000000,000000,000000,000000,0x0c00,0x1200,0x1201,
  405.           0x0c01,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  406.           0x0200,0x0400,0x0800,0x1006,0x1009,0x0009,0x0006},
  407.   /*&*/  {000000,000000,000000,000000,000000,000000,0x1078,0x1084,0x0902,
  408.           0x0601,0x0601,0x0901,0x1081,0x0042,0x0024,0x0018,0x0018,0x0024,
  409.           0x0042,0x0042,0x0042,0x0042,0x0024,0x0018,000000},
  410.   /*'*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  411.           000000,000000,000000,000000,000000,0x0001,0x0002,0x0004,0x0008,
  412.           0x0010,0x0030,0x0078,0x0078,0x0078,0x0030,000000},
  413.   /*(*/  {000000,000000,000000,000000,000000,000000,0x0080,0x0040,0x0020,
  414.           0x0020,0x0010,0x0008,0x0008,0x0004,0x0004,0x0004,0x0004,0x0004,
  415.           0x0008,0x0008,0x0010,0x0020,0x0020,0x0040,0x0080},
  416.   /*)*/  {000000,000000,000000,000000,000000,000000,0x0020,0x0040,0x0080,
  417.           0x0080,0x0100,0x0200,0x0200,0x0400,0x0400,0x0400,0x0400,0x0400,
  418.           0x0200,0x0200,0x0100,0x0080,0x0080,0x0040,0x0020},
  419.   /***/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  420.           0x1041,0x0842,0x0444,0x0248,0x0150,0x00e0,0x1fff,0x00e0,0x0150,
  421.           0x0248,0x0444,0x0842,0x1041,0x0040,0x0040,0x0040},
  422.   /*+*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  423.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x1fff,0x0040,0x0040,
  424.           0x0040,0x0040,0x0040,0x0040,000000,000000,000000},
  425.   /*,*/  {000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0030,0x0078,
  426.           0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
  427.           000000,000000,000000,000000,000000,000000,000000},
  428.   /*-*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  429.           000000,000000,000000,000000,000000,000000,0x1fff,000000,000000,
  430.           000000,000000,000000,000000,000000,000000,000000},
  431.   /*.*/  {000000,000000,000000,000000,000000,000000,000000,0x0038,0x007c,
  432.           0x007c,0x007c,0x0038,000000,000000,000000,000000,000000,000000,
  433.           000000,000000,000000,000000,000000,000000,000000},
  434.   /*-/-*/{000000,000000,000000,000000,000000,000000,000000,000000,0x0001,
  435.           0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  436.           0x0200,0x0400,0x0800,0x1000,0x1000,000000,000000},
  437.   /*0*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  438.           0x1001,0x1003,0x1005,0x1009,0x1011,0x1021,0x1041,0x1081,0x1101,
  439.           0x1201,0x1401,0x1801,0x1001,0x0802,0x0404,0x03f8},
  440.   /*1*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  441.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  442.           0x0040,0x0040,0x0040,0x0048,0x0070,0x0060,0x0040},
  443.   /*2*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
  444.           0x0001,0x0001,0x0001,0x0001,0x0002,0x03fc,0x0400,0x0800,0x1000,
  445.           0x1000,0x1000,0x1000,0x1001,0x0802,0x0404,0x03f8},
  446.   /*3*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  447.           0x1001,0x1000,0x1000,0x1000,0x0800,0x0400,0x03e0,0x0400,0x0800,
  448.           0x1000,0x1000,0x1000,0x1001,0x0802,0x0404,0x03f8},
  449.   /*4*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0200,0x0200,
  450.           0x0200,0x0200,0x0200,0x0200,0x1fff,0x0201,0x0201,0x0202,0x0204,
  451.           0x0208,0x0210,0x0220,0x0240,0x0280,0x0300,0x0200},
  452.   /*5*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  453.           0x1001,0x1000,0x1000,0x1000,0x1000,0x1000,0x0800,0x0400,0x03ff,
  454.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  455.   /*6*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  456.           0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff,0x0001,0x0001,
  457.           0x0001,0x0001,0x0002,0x0004,0x0808,0x0410,0x03e0},
  458.   /*7*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  459.           0x0002,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  460.           0x0200,0x0400,0x0800,0x0800,0x1000,0x1000,0x1fff},
  461.   /*8*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  462.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8,0x0404,0x0802,
  463.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  464.   /*9*/  {000000,000000,000000,000000,000000,000000,0x00f8,0x0104,0x0202,
  465.           0x0400,0x0800,0x1000,0x1000,0x1000,0x1000,0x1ff8,0x1004,0x1002,
  466.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  467.   /*:*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x0030,
  468.           0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
  469.           0x0030,0x0078,0x0078,0x0030,000000,000000,000000},
  470.   /*;*/  {000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0030,0x0078,
  471.           0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
  472.           0x0030,0x0078,0x0078,0x0030,000000,000000,000000},
  473.   /*<*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0100,0x0080,
  474.           0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,
  475.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200},
  476.   /*=*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  477.           000000,000000,000000,0x1fff,000000,000000,000000,000000,000000,
  478.           0x1fff,000000,000000,000000,000000,000000,000000},
  479.   /*>*/  {000000,000000,000000,000000,000000,000000,0x0008,0x0010,0x0020,
  480.           0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,0x1000,0x0800,0x0400,
  481.           0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008},
  482.   /*?*/  {000000,000000,000000,000000,000000,0x0040,0x00e0,0x0040,000000,
  483.           000000,000000,0x0040,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,
  484.           0x1000,0x1000,0x1001,0x1001,0x0802,0x0404,0x03f8},
  485.   /*@*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0002,
  486.           0x0001,0x0001,0x0ee1,0x1111,0x1111,0x1111,0x1111,0x1111,0x12e1,
  487.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  488.   /*A*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  489.           0x1001,0x1001,0x1001,0x1fff,0x1001,0x1001,0x1001,0x1001,0x0802,
  490.           0x0802,0x0404,0x0208,0x0110,0x00a0,0x00a0,0x0040},
  491.   /*B*/  {000000,000000,000000,000000,000000,000000,0x03ff,0x0408,0x0808,
  492.           0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03f8,0x0408,0x0808,
  493.           0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03ff},
  494.   /*C*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  495.           0x1001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
  496.           0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,0x03f8},
  497.   /*D*/  {000000,000000,000000,000000,000000,000000,0x03ff,0x0408,0x0808,
  498.           0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,
  499.           0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03ff},
  500.   /*E*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
  501.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x007f,0x0001,0x0001,
  502.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  503.   /*F*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  504.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x007f,0x0001,0x0001,
  505.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  506.   /*G*/  {000000,000000,000000,000000,000000,000000,0x0ff8,0x1004,0x1002,
  507.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1f01,0x0001,0x0001,
  508.           0x0001,0x0001,0x0001,0x0001,0x0002,0x1004,0x0ff8},
  509.   /*H*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  510.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1fff,0x1001,0x1001,
  511.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  512.   /*I*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  513.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  514.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x03f8},
  515.   /*J*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  516.           0x1001,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
  517.           0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1e00},
  518.   /*K*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0801,0x0401,
  519.           0x0201,0x0101,0x0081,0x0041,0x0021,0x0011,0x000f,0x0009,0x0011,
  520.           0x0021,0x0041,0x0081,0x0101,0x0201,0x0401,0x0801},
  521.   /*L*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x1001,0x1001,
  522.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
  523.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  524.   /*M*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  525.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1041,0x1041,0x10a1,
  526.           0x10a1,0x1111,0x1209,0x1209,0x1405,0x1803,0x1001},
  527.   /*N*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  528.           0x1001,0x1801,0x1401,0x1201,0x1201,0x1101,0x1081,0x1041,0x1041,
  529.           0x1021,0x1011,0x1009,0x1009,0x1005,0x1003,0x1001},
  530.   /*O*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  531.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  532.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  533.   /*P*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  534.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x03ff,0x0401,0x0801,
  535.           0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff},
  536.   /*Q*/  {000000,000000,000000,000000,0x0c00,0x0200,0x03f8,0x0494,0x0862,
  537.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  538.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  539.   /*R*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0801,0x0401,
  540.           0x0201,0x0101,0x0081,0x0041,0x0021,0x0011,0x03ff,0x0401,0x0801,
  541.           0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff},
  542.   /*S*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  543.           0x1001,0x1000,0x1000,0x1000,0x0800,0x0400,0x03f8,0x0004,0x0002,
  544.           0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,0x03f8},
  545.   /*T*/  {000000,000000,000000,000000,000000,000000,0x00e0,0x0040,0x0040,
  546.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  547.           0x0040,0x0040,0x0040,0x0040,0x0040,0x1041,0x1fff},
  548.   /*U*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  549.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  550.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  551.   /*V*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x00a0,
  552.           0x00a0,0x0110,0x0110,0x0208,0x0208,0x0404,0x0404,0x0802,0x0802,
  553.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  554.   /*W*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1803,
  555.           0x1405,0x1405,0x1209,0x1209,0x1111,0x1111,0x10a1,0x1041,0x1001,
  556.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  557.   /*X*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  558.           0x0802,0x0802,0x0404,0x0208,0x0110,0x00a0,0x0040,0x00a0,0x0110,
  559.           0x0208,0x0404,0x0802,0x0802,0x1001,0x1001,0x1001},
  560.   /*Y*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  561.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x00a0,0x0110,0x0208,
  562.           0x0404,0x0802,0x0802,0x1001,0x1001,0x1001,0x1001},
  563.   /*Z*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
  564.           0x0002,0x0004,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  565.           0x0200,0x0400,0x0400,0x0800,0x1000,0x1000,0x1fff},
  566.   /*[*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0008,0x0008,
  567.           0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,
  568.           0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x03f8},
  569.   /*\*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x1000,
  570.           0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,
  571.           0x0008,0x0004,0x0002,0x0001,0x0001,000000,000000},
  572.   /*]*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0200,0x0200,
  573.           0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,
  574.           0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x03f8},
  575.   /*^*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  576.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  577.           0x1001,0x0802,0x0404,0x0208,0x0110,0x00a0,0x0040},
  578.   /*_*/  {000000,000000,000000,000000,000000,000000,0x1fff,000000,000000,
  579.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  580.           000000,000000,000000,000000,000000,000000,000000},
  581.   /*`*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  582.           000000,000000,000000,000000,000000,0x0400,0x0200,0x0100,0x0080,
  583.           0x0040,0x0060,0x00f0,0x00f0,0x00f0,0x0060,000000},
  584.   /*a*/  {000000,000000,000000,000000,000000,000000,0x17f8,0x0804,0x0802,
  585.           0x0802,0x0802,0x0804,0x0ff8,0x0800,0x0800,0x0800,0x0800,0x0404,
  586.           0x03f8,000000,000000,000000,000000,000000,000000},
  587.   /*b*/  {000000,000000,000000,000000,000000,000000,0x03f9,0x0405,0x0803,
  588.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  589.           0x03f9,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  590.   /*c*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  591.           0x1001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,
  592.           0x03f8,000000,000000,000000,000000,000000,000000},
  593.   /*d*/  {000000,000000,000000,000000,000000,000000,0x13f8,0x1404,0x1802,
  594.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
  595.           0x13f8,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000},
  596.   /*e*/  {000000,000000,000000,000000,000000,000000,0x0ff8,0x0004,0x0002,
  597.           0x0001,0x0001,0x0001,0x1fff,0x1001,0x1001,0x1001,0x0802,0x0404,
  598.           0x03f8,000000,000000,000000,000000,000000,000000},
  599.   /*f*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  600.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x03f8,0x0040,0x0040,
  601.           0x0040,0x0040,0x0040,0x1040,0x0880,0x0500,0x0200},
  602.   /*g*/  {0x03f8,0x0404,0x0802,0x1001,0x1000,0x1000,0x13f8,0x1404,0x1802,
  603.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
  604.           0x13f8,000000,000000,000000,000000,000000,000000},
  605.   /*h*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  606.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  607.           0x03f9,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  608.   /*i*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  609.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0070,
  610.           000000,000000,000000,0x00e0,0x00e0,0x00e0,000000},
  611.   /*j*/  {0x00f0,0x0108,0x0204,0x0402,0x0400,0x0400,0x0400,0x0400,0x0400,
  612.           0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0700,
  613.           000000,000000,000000,0x0700,0x0700,0x0700,000000},
  614.   /*k*/  {000000,000000,000000,000000,000000,000000,0x0804,0x0404,0x0204,
  615.           0x0104,0x0084,0x0044,0x0024,0x0014,0x002c,0x0044,0x0084,0x0104,
  616.           0x0204,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004},
  617.   /*l*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  618.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  619.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0070},
  620.   /*m*/  {000000,000000,000000,000000,000000,000000,0x1041,0x1041,0x1041,
  621.           0x1041,0x1041,0x1041,0x1041,0x1041,0x1041,0x1041,0x08a3,0x0515,
  622.           0x0209,000000,000000,000000,000000,000000,000000},
  623.   /*n*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  624.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  625.           0x03f9,000000,000000,000000,000000,000000,000000},
  626.   /*o*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  627.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,
  628.           0x03f8,000000,000000,000000,000000,000000,000000},
  629.   /*p*/  {0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x03f9,0x0405,0x0803,
  630.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  631.           0x03f9,000000,000000,000000,000000,000000,000000},
  632.   /*q*/  {0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x13f8,0x1404,0x1802,
  633.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
  634.           0x13f8,000000,000000,000000,000000,000000,000000},
  635.   /*r*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  636.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1001,0x0803,0x0405,
  637.           0x03f9,000000,000000,000000,000000,000000,000000},
  638.   /*s*/  {000000,000000,000000,000000,000000,000000,0x03fc,0x0402,0x0800,
  639.           0x0800,0x0800,0x0400,0x03f8,0x0004,0x0002,0x0002,0x0002,0x0804,
  640.           0x07f8,000000,000000,000000,000000,000000,000000},
  641.   /*t*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0500,0x0880,
  642.           0x1040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  643.           0x07fc,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040},
  644.   /*u*/  {000000,000000,000000,000000,000000,000000,0x13f8,0x1404,0x1802,
  645.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  646.           0x1001,000000,000000,000000,000000,000000,000000},
  647.   /*v*/  {000000,000000,000000,000000,000000,000000,0x0040,0x00a0,0x0110,
  648.           0x0208,0x0404,0x0802,0x0802,0x1001,0x1001,0x1001,0x1001,0x1001,
  649.           0x1001,000000,000000,000000,000000,000000,000000},
  650.   /*w*/  {000000,000000,000000,000000,000000,000000,0x0208,0x0514,0x08a2,
  651.           0x08a2,0x1041,0x1041,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  652.           0x1001,000000,000000,000000,000000,000000,000000},
  653.   /*x*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0802,0x0404,
  654.           0x0208,0x0110,0x00a0,0x0040,0x00a0,0x0110,0x0208,0x0404,0x0802,
  655.           0x1001,000000,000000,000000,000000,000000,000000},
  656.   /*y*/  {0x03f8,0x0404,0x0802,0x1001,0x1000,0x1000,0x1000,0x1000,0x1ff8,
  657.           0x1004,0x1002,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  658.           0x1001,000000,000000,000000,000000,000000,000000},
  659.   /*z*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0002,0x0004,
  660.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,
  661.           0x1fff,000000,000000,000000,000000,000000,000000},
  662.   /*{*/  {000000,000000,000000,000000,000000,000000,0x0600,0x0100,0x0080,
  663.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0020,0x0010,0x0020,0x0040,
  664.           0x0040,0x0040,0x0040,0x0040,0x0080,0x0100,0x0600},
  665.   /*|*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  666.           0x0040,0x0040,0x0040,0x0040,000000,000000,000000,000000,000000,
  667.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040},
  668.   /*}*/  {000000,000000,000000,000000,000000,000000,0x000c,0x0010,0x0020,
  669.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0080,0x0100,0x0080,0x0040,
  670.           0x0040,0x0040,0x0040,0x0040,0x0020,0x0010,0x000c},
  671.   /*~*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  672.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  673.           0x0600,0x0900,0x1080,0x1041,0x0021,0x0012,0x000c},
  674.   /*DEL*/{000000,000000,000000,000000,000000,000000,0x1249,000000,000000,
  675.           0x1249,000000,000000,0x1249,000000,000000,0x1249,000000,000000,
  676.           0x1249,000000,000000,0x1249,000000,000000,0x1249},
  677. };
  678.  
  679. /*
  680. ** The plotting area is defined as a huge bitmap.
  681. ** The bitmap is stored in a dynamically allocated pixel array b_p
  682. **
  683. ** The bitmap is allocated (and initialized to zero) with
  684. ** b_makebitmap(xsize, ysize, planes)
  685. ** and freed with b_freebitmap()
  686. ** xsize and ysize will be rounded up to a multiple of 8.
  687. **
  688. ** Valid (int) coordinates range from zero to (xsize-1,ysize-1)
  689. **
  690. ** Plotting is done via b_move(x, y) and b_vector(x, y) functions,
  691. ** where the point (x,y) is the target to go from the current point
  692. ** To set the color use b_setvalue(value) where value is the value 
  693. ** (0 or 1 or a color number) to be stored in every pixel.
  694. ** To get dotted line styles, use b_setlinetype(linetype).
  695. **
  696. ** Internally all plotting goes through b_setpixel(x, y, value).
  697. */
  698.  
  699.  
  700. /*
  701. ** set pixel (x, y, value) to value value (this can be 1/0 or a color number).
  702. */
  703. void
  704. b_setpixel(x, y, value)
  705. unsigned int x, y, value;
  706. {
  707.   register unsigned int row;
  708.   register unsigned char mask;
  709.   int i;
  710.   if (b_rastermode) {
  711.     /* interchange so that new (x,y) is old (y,b_ysize-1-x) */
  712.     row = x;  /* temp storage */
  713.     x = y;
  714.     y = b_ysize-1-row;
  715.   }
  716.   if (IN(x, b_xsize) && IN(y, b_ysize))
  717.   {
  718.     row = y/8;
  719.     mask = 1<<(y%8);
  720.  
  721.     for (i=0; i<b_planes; i++) {
  722.         if (value&1)
  723.             *((*b_p)[row]+x) |= mask;
  724.         else
  725.             *((*b_p)[row]+x) &= ~mask;
  726.         row += b_psize;
  727.         value >>= 1;
  728.     }
  729.   }
  730. #ifdef BITMAPDEBUG
  731.   else
  732.   {
  733.     if (b_rastermode)
  734.       fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n", 
  735.         b_ysize-1-y, x, value);
  736.     else
  737.       fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n",
  738.         x, y, value);
  739.   }
  740. #endif
  741. }
  742.  
  743. /*
  744. ** get pixel (x,y) value----unused
  745. */
  746. /****************************
  747. unsigned int
  748. b_getpixel(x, y)
  749. unsigned int x, y;
  750. {
  751.   register unsigned int row;
  752.   register unsigned char mask;
  753.   register unsigned char value;
  754.   int i;
  755.  
  756.   if (b_rastermode) {
  757.     row = x;
  758.     x = y;
  759.     y = b_ysize-1-row;
  760.   }
  761.   if (IN(x, b_xsize) && IN(y, b_ysize))
  762.   {
  763.     row = y/8 + (b_planes-1)*b_psize;
  764.     mask = 1<<(y%8);
  765.  
  766.     for (i=0; i<b_planes; i++) {
  767.         if ( *((*b_p)[row]+x) & mask )
  768.             value |= 1;
  769.         row -= b_psize;
  770.         value <<= 1;
  771.     }
  772.     return(value);
  773.   }
  774.   else
  775.   {
  776. #ifdef BITMAPDEBUG
  777.     if (b_rastermode)
  778.       fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n",
  779.         b_ysize-1-y, x);
  780.     else
  781.       fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n", x, y);
  782. #endif
  783.     return(0);
  784.   }
  785. }
  786. ********************************/
  787.  
  788. /*
  789. ** allocate the bitmap
  790. */
  791. void
  792. b_makebitmap(x, y, planes)
  793. unsigned int x, y, planes;
  794. {
  795.   register unsigned j;
  796.   unsigned rows;
  797.  
  798.   x = 8 * (unsigned int)(x/8.0+0.9);    /* round up to multiple of 8 */
  799.   y = 8 * (unsigned int)(y/8.0+0.9);    /* round up to multiple of 8 */
  800.   b_psize = y/8;                    /* size of each plane */
  801.   rows = b_psize * planes;            /* total number of rows of 8 pixels high */
  802.   b_xsize = x; b_ysize = y;
  803.   b_currx = b_curry = 0;
  804.   b_planes = planes;
  805.   b_value = 1;
  806.   b_angle = 0;
  807.   b_rastermode = 0;
  808.   /* allocate row pointers */
  809.   b_p = (bitmap *)alloc( (unsigned long)rows * sizeof(pixels *), "bitmap row buffer");
  810.   bzero(b_p, rows * sizeof(pixels *));
  811.   for (j = 0; j < rows; j++) {
  812.     /* allocate bitmap buffers */
  813.     (*b_p)[j] = (pixels *)alloc((unsigned long)x * sizeof(pixels),(char *)NULL);
  814.     if ((*b_p)[j] == (pixels *)NULL) {
  815.         b_freebitmap();  /* free what we have already allocated */
  816.         int_error("out of memory for bitmap buffer", NO_CARET);
  817.     }
  818.     bzero((*b_p)[j], x * sizeof(pixels));
  819.   }
  820. }
  821.   
  822. /*
  823. ** free the allocated bitmap
  824. */
  825. void
  826. b_freebitmap()
  827. {
  828.   int j;
  829.   unsigned rows;
  830.  
  831.   rows = b_psize * b_planes;   /* total number of rows of 8 pixels high */
  832.   for (j = 0; j < rows; j++)
  833.   {
  834.     (void) free((char *)(*b_p)[j]);
  835.   }
  836.   (void) free((char *)b_p);
  837.   b_p = (bitmap *)(NULL);
  838. }
  839.  
  840. /*
  841. ** set pixel at (x,y) with color b_value and dotted mask b_linemask.
  842. */
  843. void
  844. b_setmaskpixel(x,y,value)
  845. unsigned int x,y,value;
  846. {
  847.     /* dotted line generator */
  848.     if ((b_linemask>>b_maskcount)&(unsigned int)(1)) {
  849.         b_setpixel(x,y,value);
  850.     }
  851.     b_maskcount= (b_maskcount+1) % 16;
  852.     b_lastx= x;  /* last pixel set with mask */
  853.     b_lasty= y;
  854. }
  855.  
  856. /*
  857. ** draw a line from (x1,y1) to (x2,y2)
  858. ** with color b_value and dotted mask b_linemask.
  859. */
  860. void
  861. b_line(x1,y1,x2,y2)
  862. unsigned int x1,y1,x2,y2;
  863. {
  864. int runcount;
  865. int dx,dy;
  866. int xinc,yinc;
  867. unsigned int xplot,yplot;
  868.  
  869.     runcount=0;
  870.     dx = abs((int)(x1)-(int)(x2));
  871.     if (x2>x1)  xinc=  1;
  872.     if (x2==x1) xinc=  0;
  873.     if (x2<x1)  xinc= -1;
  874.     dy = abs((int)(y1)-(int)(y2));
  875.     if (y2>y1)  yinc=  1;
  876.     if (y2==y1) yinc=  0;
  877.     if (y2<y1)  yinc= -1;
  878.     xplot=x1;
  879.     yplot=y1;
  880.     if (dx>dy) {
  881.         /* iterate x */
  882.         if ( (b_linemask==0xffff) ||
  883.             ((xplot!=b_lastx) && (yplot!=b_lasty)) )
  884.             b_setmaskpixel(xplot,yplot,b_value);
  885.         while (xplot!=x2) {
  886.             xplot+=xinc;
  887.             runcount+=dy;
  888.             if (runcount>=(dx-runcount)) {
  889.                 yplot+=yinc;
  890.                 runcount-=dx;
  891.             }
  892.             b_setmaskpixel(xplot,yplot,b_value);
  893.         }
  894.     } else {
  895.         /* iterate y */
  896.         if ( (b_linemask==0xffff) ||
  897.             ((xplot!=b_lastx) && (yplot!=b_lasty)) )
  898.             b_setmaskpixel(xplot,yplot,b_value);
  899.         while (yplot!=y2) {
  900.             yplot+=yinc;
  901.             runcount+=dx;
  902.             if (runcount>=(dy-runcount)) {
  903.                 xplot+=xinc;
  904.                 runcount-=dy;
  905.             }
  906.             b_setmaskpixel(xplot,yplot,b_value);
  907.         }
  908.     }
  909. }
  910.  
  911. /*
  912. ** set character size
  913. */
  914. void
  915. b_charsize(size)
  916. unsigned int size;
  917. {
  918.     int j;
  919.     switch(size) {
  920.         case FNT5X9:
  921.             b_hchar = FNT5X9_HCHAR;
  922.             b_hbits = FNT5X9_HBITS;
  923.             b_vchar = FNT5X9_VCHAR;
  924.             b_vbits = FNT5X9_VBITS;
  925.             for (j = 0; j < FNT_CHARS; j++ )
  926.                 b_font[j] = &fnt5x9[j][0];
  927.             break;
  928.         case FNT9X17:
  929.             b_hchar = FNT9X17_HCHAR;
  930.             b_hbits = FNT9X17_HBITS;
  931.             b_vchar = FNT9X17_VCHAR;
  932.             b_vbits = FNT9X17_VBITS;
  933.             for (j = 0; j < FNT_CHARS; j++ )
  934.                 b_font[j] = &fnt9x17[j][0];
  935.             break;
  936.         case FNT13X25:
  937.             b_hchar = FNT13X25_HCHAR;
  938.             b_hbits = FNT13X25_HBITS;
  939.             b_vchar = FNT13X25_VCHAR;
  940.             b_vbits = FNT13X25_VBITS;
  941.             for (j = 0; j < FNT_CHARS; j++ )
  942.                 b_font[j] = &fnt13x25[j][0];
  943.             break;
  944.         default:
  945.             int_error("Unknown character size",NO_CARET);
  946.     }
  947. }
  948.  
  949.  
  950. /*
  951. ** put characater c at (x,y) rotated by angle with color b_value.
  952. */
  953. void
  954. b_putc(x,y,c,angle)
  955. unsigned int x,y;
  956. char c;
  957. unsigned int angle;
  958. {
  959.     unsigned int i, j, k;
  960.     char_row fc;
  961.  
  962.     j = c - ' ';
  963.     for ( i = 0; i < b_vbits; i++ ) {
  964.         fc = *( b_font[j] + i );
  965.         if ( c == '_' ) {    /* treat underline specially */
  966.             if ( fc  ) {    /* this this the underline row ? */
  967.                 /* draw the under line for the full h_char width */
  968.                 for ( k = ( b_hbits - b_hchar )/2;
  969.                     k < ( b_hbits + b_hchar )/2; k++ ) {
  970.                     switch(angle) {
  971.                         case 0 : b_setpixel(x+k+1,y+i,b_value);
  972.                             break;
  973.                         case 1 : b_setpixel(x-i,y+k+1,b_value);
  974.                             break;
  975.                     }
  976.                 }
  977.             }
  978.         }
  979.         else {
  980.             /* draw character */
  981.             for ( k = 0; k < b_hbits; k++ ) {
  982.                 if ( ( fc >> k ) & 1 ) {
  983.                     switch(angle) {
  984.                         case 0 : b_setpixel(x+k+1,y+i,b_value);
  985.                             break;
  986.                         case 1 : b_setpixel(x-i,y+k+1,b_value);
  987.                             break;
  988.                     }
  989.                 }
  990.             }
  991.         }
  992.     }
  993. }
  994.  
  995.  
  996. /*
  997. ** set b_linemask to b_pattern[linetype]
  998. */
  999. int
  1000. b_setlinetype(linetype)
  1001. int linetype;
  1002. {
  1003.     if (linetype>=7)
  1004.         linetype %= 7;
  1005.     b_linemask = b_pattern[linetype+2];
  1006.     b_maskcount=0;
  1007. }
  1008.  
  1009. /*
  1010. ** set b_value to value
  1011. */
  1012. void
  1013. b_setvalue(value)
  1014. unsigned int value;
  1015. {
  1016.     b_value = value;
  1017. }
  1018.  
  1019. /*
  1020. ** move to (x,y)
  1021. */
  1022. int
  1023. b_move(x, y)
  1024. unsigned int x, y;
  1025. {
  1026.   b_currx = x;
  1027.   b_curry = y;
  1028. }
  1029.  
  1030. /*
  1031. ** draw to (x,y) with color b_value
  1032. */
  1033. int
  1034. b_vector(x, y)
  1035. unsigned int x, y;
  1036. {
  1037.   b_line(b_currx, b_curry, x, y);
  1038.   b_currx = x;
  1039.   b_curry = y;
  1040. }
  1041.  
  1042.  
  1043. /*
  1044. ** put text str at (x,y) with color b_value and rotation b_angle
  1045. */
  1046. int
  1047. b_put_text(x,y,str)
  1048. unsigned int x, y;
  1049. char *str;
  1050. {
  1051.     if (b_angle == 1)
  1052.         x += b_vchar/2;
  1053.     else
  1054.         y -= b_vchar/2;
  1055.    switch (b_angle) {
  1056.       case 0:
  1057.      for (; *str; ++str, x += b_hchar)
  1058.         b_putc (x, y, *str, b_angle);
  1059.                     break;
  1060.       case 1:
  1061.      for (; *str; ++str, y += b_hchar)
  1062.         b_putc (x, y, *str, b_angle);
  1063.                     break;
  1064.     }
  1065. }
  1066.  
  1067.  
  1068. int
  1069. b_text_angle(ang)
  1070. int ang;
  1071. {
  1072.     b_angle=(unsigned int)ang;
  1073.     return TRUE;
  1074. }
  1075.